package com.ququ.syb.entrance.controller;

import com.ququ.syb.entrance.po.RequestData;
import com.ququ.syb.entrance.service.WithdrawService;
import com.ququ.syb.entrance.vo.SybResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 提现服务模块
 *
 * @author macro
 * @date 2019-08-26
 *
 */
@RestController
@RequestMapping("/syb/controller")
public class WithdrawController {
    @Autowired
    private WithdrawService withdrawService;


    /**
     * /p1001 提现服务接口
     *
     *
     * @param header.terminalno 终端号，随便填|必填
     * @param header.requesttype 请求类型，默认为1|必填
     * @param header.operationid 请求id|必填
     * @param header.appcode 应用代码|必填
     * @param header.terminaltype 默认填1|必填
     * @param header.timestamp 时间戳|必填
     * @param encryptiontype 加密方式 1-AES加密 3-明文，这里填1|必填
     * @param accountid 生意宝账户|必填
     * @param data 业务数据请求部分，JSON格式，AES加密|必填
     * @param data.amount 提现金额，单位为分|必填
     * @param data.outorderno 提现商户订单号|必填
     * @param data.tradenum 指定提现订单号，特殊情况下使用
     * @param data.paychannelid 提现通道号|必填
     * @param data.withdrawtype 出款周期类型 0-D0 1-D1 2-T1，默认为0
     * @param data.callbackurl 提现回调地址
     * @return 提现订单基本信息
     * @respbody {"status":1,"msg":"成功","data":{"accountid":"100000000064","result":"Q4+b/oGWRzsbOFU6Lu6Q9+cLK1J/lomLyFoE9NM2wjJkPhcU+pCTvi7zYeW0LT31TOP8nyRzI0pvNJi9pjvVWs07Vl7H5gecARoemrZ6w4A/Poqzcct77tDfp3cx3xTKkfGqDzh68UyiH3dsa32JJz//wbJ8j7ZYpjgJ7qGgQa9F+y8K/MfvWooaxp0HPMWSZYM9mO/KsIA312TWHBzGX4v4ap6Jk/DuIVItiuvn81gyEb0ElpU79gPcVmb2sWOF3UGA7ksycDbft1E7kgDKXGSC0vcVa/E97miadcRrSbV5nz4zeMEMzHQ0gQ2jhe73"},"page":{"count":1,"index":1,"size":10,"total":1},"sign":"938b71581c80f095df336a286d2e9baa"}
     * @resp status 状态值，1-成功 其他值-失败|int
     * @resp msg 错误信息|string
     * @resp data.accountid 生意宝账号id|string
     * @resp data.result 明文 |string
     * @resp data.result.outorderno 商户订单号|string
     * @resp data.result.tradenum 生意宝提现订单号|string
     * @resp data.result.commission 提现手续费|string
     * @resp data.result.amount 提现订单金额，单位为分|int
     * @resp data.result.realamount 实际到账金额，单位为分|int
     * @resp page 分页信息，可忽略|object
     *
     */
    @RequestMapping("/p1001")
    public SybResult withdraw(@RequestHeader String appcode,
                                @RequestHeader(required = false) String timeStamp,
                                @RequestHeader(required = false) String operationid,
                                @RequestHeader(required = false) String operationname,
                                @RequestParam String accountid,
                                @RequestParam String data,
                                @RequestParam String sign,
                                @RequestParam Integer encryptiontype){
        RequestData<String> requestData = new RequestData<>(appcode,accountid,operationid,operationname,data,sign,encryptiontype);
        return withdrawService.withdraw(requestData);
    }

}
